//
//  BloginViewController.m
//  penzer
//
//  Created by caiyc on 2018/10/6.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "BloginViewController.h"
#import "BIndexViewController.h"
#import "RZTabBarController.h"
@interface BloginViewController ()<UIScrollViewDelegate>

@end

@implementation BloginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.botom_ScroView.contentSize = CGSizeMake(0, screen_height*1.3);
    self.botom_ScroView.delegate = self;
    UITapGestureRecognizer *taps = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideKb)];
    [self.view addGestureRecognizer:taps];
    // Do any additional setup after loading the view from its nib.
    self.mob_Tf.text = @"tongshikai";
    self.password_tf.text = @"123456";
}


-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    [self.view endEditing:1];
}
-(void)hideKb{
    [self.view endEditing:1];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)login:(Regular_Btn *)sender {
    [self.view endEditing: 1];
    
    
    /**
     http://dev.sharepanzer.com/api/bzapi.php?i=10&c=entry&ctrl=live_merch&ac=auth&op=login&m=bz_activities&ta=merch_login&account=tongshikai&password=123456
    参数 account 账号 password 密码
     */

    if([self.mob_Tf.text isEqualToString:@""]||[self.password_tf.text isEqualToString:@""]){
        [WToast showWithText:@"请填写完整的登录信息"];
        return;
    }
    
    HelenParametersDic *dict = [HelenParametersDic h_dictionary];
    dict[@"account"] = self.mob_Tf.text;
    dict[@"password"] = self.password_tf.text;
    dict[@"ac"] = @"auth";
    dict[@"op"] = @"login";
    dict[@"ac"] = @"auth";
    dict[@"ta"] = @"merch_login";
    
    [HelenHttpClient requestWithUrlString:BASE_URL andParam:dict andMethod:@"POST" progress:nil success:^(id responseObject) {
        
        NSDictionary *res = responseObject[@"message"];
        NSInteger code = [res[@"resultCode"] integerValue];
        if(code== 0 || code ==1){
            
            NSDictionary *userInfo = [NSDictionary changeType:res[@"data"]] ;
            [XTool SaveDefaultInfo:@"2" Key:Prole];
            [XTool SaveDefaultInfo:userInfo Key:BUSSION_INFO];
            
            [UIApplication sharedApplication].keyWindow.rootViewController = [RZTabBarController new];
            [WToast showWithText:@"登录成功"];
            
        }else{
            [WToast showWithText:res[@"resultMessage"]];
        }
        
    } andFailBlock:^(NSInteger ErrorCode, NSError *ErrorString) {
        
    }];
    
//    NSDictionary *params = @{@"ctrl":@"live_anchor",@"ac":@"auth",@"op":@"login",@"mobile":self.mob_Tf.text,@"password":self.password_tf.text,@"ta":@"index"};
//    [self weqPostHandle:params success:^(id response) {
//        if(response){
//            NSDictionary *userInfo = [NSDictionary changeType:response[@"data"]] ;
//            [XTool SaveDefaultInfo:@"2" Key:Prole];
//            [XTool SaveDefaultInfo:userInfo Key:BUSSION_INFO];
////            BIndexViewController *vc = [[BIndexViewController alloc]init];
////            [self pushSecondVC:vc];
//            if([[UIApplication sharedApplication].keyWindow.rootViewController isEqual:[RZTabBarController defaultTabVc]]){
//                [self.navigationController popToRootViewControllerAnimated:YES];
//            }else{
//                [UIApplication sharedApplication].keyWindow.rootViewController = [RZTabBarController defaultTabVc];
//            }
//
//        }
//    } failure:^(NSError *error) {
//
//    }];
    
}



- (IBAction)showPass:(id)sender {
    self.password_tf.secureTextEntry = !self.password_tf.secureTextEntry;
}
@end
